<?php

declare(strict_types=1);

namespace App\Controller\AdminApi;

use App\Middleware\AdminJWTAuthMiddleware;
use App\Service\RiskParamService;
use Dotenv\Validator;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\DeleteMapping;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
use App\Exception\XZXValidationException;
use App\Service\XeSampleService;
use App\Utils\CustomUtils;
use Psr\Container\ContainerInterface;
use Hyperf\Logger\LoggerFactory;

/**
 * Class RiskParamController
 *
 * @package App\Controller
 * @Controller(prefix="/admin/api/riskParam")
 * @Middleware(AdminJWTAuthMiddleware::class)
 */
class RiskParamController extends AdminBaseController {

    /**
     * @Inject()
     * @var ValidatorFactoryInterface
     *
     */
    protected $validationFactory;


    /**
     * @Inject()
     * @var RiskParamService
     */
    protected $RiskParamService;

    /**
     * @var \Psr\Log\LoggerInterface
     */
    protected $logger;

    public function __construct (LoggerFactory $loggerFactory) {
        // 第一个参数对应日志的 name, 第二个参数对应 config/autoload/logger.php 内的 key
        $this->logger = $loggerFactory->get('log', 'default');
    }

    /**
     * 列表
     * @PostMapping(path = "list")
     */
    public function list (RequestInterface $request) {

        $param = $request->all();
        return $this->RiskParamService->list($param);
    }

    /**
     * 下拉框选项
     * @PostMapping(path = "options")
     */
    public function options (RequestInterface $request) {

        $param = $request->all();
        return $this->RiskParamService->options($param);
    }
}
